package billeterie;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
import java.util.Random;
/**
 * 
 * @author samir
 */
public class FillDataBase {

    Random r = new Random();

    // <editor-fold defaultstate="collapsed" desc="randomNames">
    public Map<String, String> randomNames() {
        Map<String, String> returnFullNames = new HashMap<>();
        String[] noms = {"Pierre", "Paul", "Jaques", "Jean", "Gustave", "Robert", "Bertrand", "Geraldine", "Francoise", "Solange", "Jasmine", "Aladin", "Genie", "Phillipe", "Michael", "Nicolas", "Berret", "Marouch", "Fred", "Maxim", "Lasange", "Linda", "Sarra", "Bouvier", "Mounir", "Patrice", "Nico", "Biot", "Mango", "Frederic", "Matri", "Leclerc", "Lee", "Sarona", "Bouvant",
            "Martin", "Legrand", "Bernard", "Garnier", "Dubois", "Faure", "Thomas", "Rousseau", "Robert", "Blanc", "Richard", "Guerin", "Petit", "Muller", "Durand", "Henry", "Leroy", "Roussel", "Moreau", "Nicolas", "Simon", "Perrin", "Laurent", "Morin", "Lefebvre", "Mathieu", "Michel", "Clement", "Garcia", "Gauthier", "David", "Dumont", "Bertrand", "Lopez", "Roux", "Fontaine", "Vincent", "Chevalier", "Fournier", "Robin", "Morel", "Masson", "Girard", "Sanchez", "Andre", "Gerard", "Lefevre", "Nguyen", "Mercier", "Boyer", "Dupont", "Denis", "Lambert", "Lemaire", "Bonnet", "Duval", "Francois", "Joly", "Martinez", "Gautier"};
        for (int i = 0; i < noms.length; i++) {
            String nom = noms[r.nextInt(noms.length)], prenom = noms[r.nextInt(noms.length)];
            if (!nom.equals(prenom)) { //pour eviter que la personne posséde le meme nom et prenom
                returnFullNames.put(nom, prenom);
            }
        }
        return returnFullNames;
    }
    public String randomPrefix() {
        String[] noms = {"Saint", "Jean-Jack", "Piere", "De"};
        return noms[r.nextInt(noms.length)];
    }
// </editor-fold>
    // <editor-fold defaultstate="collapsed" desc="randomVilles(villeDepart)">

    public String[] randomVilles() {
        String[] vil = {"Paris", "Marseille", "Lyon", "Toulouse", "Nice", "Nantes", "Strasbourg", "Montpellier", "Bordeaux", "Saint-Étienne", "Colomiers", "Amien", "Brest"};
        String[] vile = new String[132];
        for (int k = 0, i = 0; i < vil.length; i++) {
            for (int j = 0; j < 11; j++) {
                if (i != j) {
                    vile[k] = vil[i] + "#" + vil[j];
                    k++;
                }
            }
        }
        return (vile);
    }
// </editor-fold>
    // <editor-fold defaultstate="collapsed" desc="randomAdresse">

    public String randomAdresse() {
        ArrayList<String> villes = new ArrayList<>();
        String[] ville = {"Paris", "Marseille", "Lyon", "Toulouse", "Nice", "Nantes", "Strasbourg", "Montpellier", "Bordeaux", "Saint-Étienne", "Colomiers", "Saint-Benoît", "Villefranche-sur-Saône"};
        int j = 0;
        while (j < ville.length) {
            villes.add(ville[j]);
            j++;
        }
        String villeR = "";
        villeR = villes.get(r.nextInt(villes.size()));

        return (r.nextInt(200) + " rue " + r.nextInt(200) + ", " + villeR + ".");
    }
// </editor-fold>
    // <editor-fol
    
    public String randomVille() {
        ArrayList<String> villes = new ArrayList<>();
        String[] ville = {"Paris", "Marseille", "Lyon", "Toulouse", "Nice", "Nantes", "Strasbourg", "Montpellier", "Bordeaux", "Saint-Étienne", "Colomiers", "Saint-Benoît", "Villefranche-sur-Saône"};
        int j = 0;
        while (j < ville.length) {
            villes.add(ville[j]);
            j++;
        }
        String villeR = villes.get(r.nextInt(villes.size()));
        return (villeR);
    }
// </editor-fold>
    // <editor-fold defaultstate="collapsed" desc="returnIdGare">

//    public int returnIdGare(String gare) {
//        String[] ville = {"Paris", "Marseille", "Lyon", "Toulouse", "Nice", "Nantes", "Strasbourg", "Montpellier", "Bordeaux", "Saint-Étienne", "Colomiers", "Saint-Benoît", "Villefranche-sur-Saône"};
//        int j = 0;
//        while (!ville[j].equals(gare)) {
//            j++;
//        }
//        return (j);
//    }
// </editor-fold>
    // <editor-fold defaultstate="collapsed" desc="randomDistance">

    public int randomDistance() {
        return (r.nextInt(3000));
    }
// </editor-fold>
    // <editor-fold defaultstate="collapsed" desc="randomDate">

    public String randomDate(int type) {
        String jour = String.format("%d", r.nextInt(30) + 1), mois = String.format("%d", r.nextInt(11) + 1);
        if (jour.length() == 1) {
            jour = "0" + jour;
        }
        if (mois.length() == 1) {
            mois = "0" + mois;
        }

        if (type == 1) {
            return jour + "/" + mois + "/" + "198" + r.nextInt(10);
        } else {
            return jour + "/01/2014";
        }
    }
    // </editor-fold>
    // <editor-fold defaultstate="collapsed" desc="randomType">

    public String randomType() {
        ArrayList<String> typeList = new ArrayList<String>();
        typeList.add("Classic");
        typeList.add("TGV");

        Random r = new Random();
        String type = typeList.get(r.nextInt(typeList.size()));
        return type;
    }

    // </editor-fold>
    // <editor-fold defaultstate="collapsed" desc="randomListNumber">
    public List<Integer> randomListNumber(int nombreBillet) {
        List<Integer> siege = new LinkedList<>();
        int k = 0;
        boolean exist = false;
        for (; k < nombreBillet;) {
            int temp = r.nextInt(nombreBillet);
            for (int j = 0; j < siege.size(); j++) {
                if (temp == siege.get(j)) {
                    exist = true;
                    break;
                } else {
                    exist = false;
                }
            }
            if (exist == false) {
                siege.add(temp);
                k++;
            }
        }
        return siege;
    }
    // </editor-fold>
}